package com.ssy.lingxi.purchase.entity.notice;

import com.ssy.lingxi.purchase.entity.converter.JpaJsonToLongListConverter;
import com.ssy.lingxi.purchase.entity.converter.JpaJsonToShopIdConverter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 采购公示
 * @author fhj
 * @date 2021/05/26
 * @version 2.0.0
 */
@Data
@Entity
@Table(schema = "public", name = "pu_purchase_notice")
public class PurchaseNotice {

    @Id
    @GeneratedValue(strategy= GenerationType.SEQUENCE, generator="purchase_notice_seq")
    @SequenceGenerator(sequenceName="pu_purchase_notice_seq", name="purchase_notice_seq", allocationSize = 1)
    @ApiModelProperty(value = "ID")
    private Long id;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "发布人会员ID")
    private Long memberId;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "发布人角色ID")
    private Long roleId;

    @Column(columnDefinition = "int2")
    @ApiModelProperty(value = "类型：1.询价；2.招标；3.竞价；")
    private Integer type;

    @Column(columnDefinition = "varchar(256)")
    @ApiModelProperty(value = "项目名称（摘要）")
    private String name;

    @Column(columnDefinition = "varchar(512)")
    @ApiModelProperty(value = "内容")
    private String content;

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "发布时间")
    private Long createTime;

    @Convert(converter = JpaJsonToLongListConverter.class)
    @Column(columnDefinition = "jsonb")
    @ApiModelProperty(value = "相关会员ID（报名、报价）")
    private List<Long> memberIds = new ArrayList<>();

    @Column(columnDefinition = "int8")
    @ApiModelProperty(value = "数据ID")
    private Long dataId;

    /**
     * 发布需求 绑定的商城Id
     */
    @Convert(converter = JpaJsonToShopIdConverter.class)
    @Column(columnDefinition = "jsonb")
    private List<Long> shopIds;}
